package com.t.bricks.bussiness.service.document.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.t.bricks.bussiness.db.dao.document.DocumentDao;
import com.t.bricks.bussiness.db.entity.document.Document;
import com.t.bricks.bussiness.service.document.DocumentService;
import com.t.bricks.model.MsgEmity;

/**
 * 档案管理'Document表'基本业务操作类接口实现
 */
@Service
public class DocumentServiceImpl implements DocumentService<Document> {

	@Autowired
	private DocumentDao<Document> documentDao;

	/**
	 * 根据编号和分享值获取文件路径
	 * @param sId 记录编号
	 * @param sSharesKey 分享码(在非共享下可通过此分享码查看)
	 * @return
	 */
	@Override
	public MsgEmity getFilePath(String sId, String sSharesKey) {
		if (null == sId || "".equals(sId.trim())) {
			return new MsgEmity(false, "编号不能为空！", 8001);
		}
		
		if (null != sSharesKey && sSharesKey.trim().length() != 5) {
			return new MsgEmity(false, "分享码长度错误！", 8002);
		}
		
		return documentDao.getFilePath(sId, sSharesKey.trim());
	}

}
